import { mapState,mapMutations,mapActions } from 'vuex'


export const likeListMixin = {
	computed:{
		...mapState([
			'likeObjList'
		])
	},
	methods:{
		...mapActions(['deleteLikeArray']),
		...mapMutations(['SAVE_LIKE']),
		toggleFavorite(workObj) {
		  if (this.isFavorite(workObj)) {
			  this.SAVE_LIKE(workObj)
		  } else {
			  this.deleteLikeArray(state.likeObjList,workObj)
		  }
		},
		getFavoriteIcon(workObj) {
		  if (this.isFavorite(workObj)) {
			return 'icon-favorite'
		  }
		  return 'icon-not-favorite'
		},
		isFavorite(workObj) {
		  const index = this.likeObjList.findIndex((item) => {
			return item.id === song.id
		  })
		  return index > -1
		},
		
	}
}